package com.minisoft.pms;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;

public class SOAPClient {
    public static void main(String[] args) {
        // 构建 SOAP 请求的 XML 消息
        String soapRequest = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ws=\"webservice.InitProcess.westvalley.com\">\n" +
                "   <soapenv:Header/>\n" +
                "   <soapenv:Body>\n" +
                "      <web:createOrUpdateWorkflow>\n" +
                "            <workflowRequestInfo>\n" +
                "                <saplcbh>f519215dc52a434dbd7899f62dcbcb90</saplcbh>\n" +
                "                <saplclx>PMS</saplclx>\n" +
                "                <creatorId>linshuying</creatorId>\n" +
                "                <isNext>0</isNext>\n" +
                "                <requestName>华发数智项目变更审批表</requestName>\n" +
                "                <workflowId>22442</workflowId>\n" +
                "                <workflowMainTableInfo>\n" +
                "                    <workflowRequestTableField>\n" +
                "                        <fieldType>ftp:文件名称1|http:文件名称2</fieldType>\n" +
                "                        <fieldName>fj</fieldName>\n" +
                "                        <fieldValue>ftp://XXXXXXXX|http://XXXXXXXX</fieldValue>\n" +
                "                    </workflowRequestTableField>\n" +
                "                    <workflowRequestTableField>\n" +
                "                        <fieldName>test</fieldName>\n" +
                "                        <fieldValue>123</fieldValue>\n" +
                "                    </workflowRequestTableField>\n" +
                "                </workflowMainTableInfo>\n" +
                "                <workflowDetailTableInfos>\n" +
                "                    <workflowDetailTable>\n" +
                "                        <id>0</id>\n" +
                "                        <workflowRequestTableRecords>\n" +
                "                            <workflowRequestTableField>\n" +
                "                                <fieldName>sqr</fieldName>\n" +
                "                                <fieldValue>linshuying</fieldValue>\n" +
                "                            </workflowRequestTableField>\n" +
                "                            <workflowRequestTableField>\n" +
                "                                <fieldName>ce</fieldName>\n" +
                "                                <fieldValue>测试</fieldValue>\n" +
                "                            </workflowRequestTableField>\n" +
                "                        </workflowRequestTableRecords>\n" +
                "                        <workflowRequestTableRecords>\n" +
                "                            <workflowRequestTableField>\n" +
                "                                <fieldName>sqr</fieldName>\n" +
                "                                <fieldValue>linshuying</fieldValue>\n" +
                "                            </workflowRequestTableField>\n" +
                "                            <workflowRequestTableField>\n" +
                "                                <fieldName>ce</fieldName>\n" +
                "                                <fieldValue>测试</fieldValue>\n" +
                "                            </workflowRequestTableField>\n" +
                "                        </workflowRequestTableRecords>\n" +
                "                    </workflowDetailTable>\n" +
                "                    <workflowDetailTable>\n" +
                "                        <id>1</id>\n" +
                "                        <workflowRequestTableRecords>\n" +
                "                            <workflowRequestTableField>\n" +
                "                                <fieldName>fenb</fieldName>\n" +
                "                                <fieldValue>0706</fieldValue>\n" +
                "                            </workflowRequestTableField>\n" +
                "                            <workflowRequestTableField>\n" +
                "                                <fieldName>bum</fieldName>\n" +
                "                                <fieldValue>0817</fieldValue>\n" +
                "                            </workflowRequestTableField>\n" +
                "                        </workflowRequestTableRecords>\n" +
                "                    </workflowDetailTable>\n" +
                "                </workflowDetailTableInfos>\n" +
                "            </workflowRequestInfo>\n" +
                "      </web:createOrUpdateWorkflow>\n" +
                "   </soapenv:Body>\n" +
                "</soapenv:Envelope>";

        // 发送 SOAP 请求
        HttpResponse response = HttpRequest.post("http://172.16.51.245:88/services/InitProcessInterface")
                .header("Content-Type", "text/xml; charset=utf-8")
                .header("SOAPAction", "") // SOAPAction 为空
                .body(soapRequest)
                .execute();

        // 输出响应
        System.out.println("Response: " + response.body());
    }
}